Introduction to CSS

Learn how Cascading Style Sheets shape the visual language of the web: selectors, properties, layout, spacing, colors, and more.

🎯 Objectives

By the end of this tutorial, you will:


πŸ“š Content Overview

1. CSS Basics: Selectors, Properties, and Values (1 Hour)

CSS (Cascading Style Sheets) controls how HTML elements appear on a webpage.

✨ Structure of a CSS Rule

A CSS rule consists of:

selector {
    property: value;
}
  

🎯 Example

h1 {
    color: blue;
    text-align: center;
}
  

✨ Common Selectors

Element Selector: Targets all instances of an element.

p {
    font-size: 16px;
}
  

Class Selector: Targets elements with a specific class.

.highlight {
    background-color: yellow;
}
  

HTML Example:

<p class="highlight">This is highlighted!</p>
  

ID Selector: Targets a specific element with an ID.

#unique {
    border: 1px solid black;
}
  

HTML Example:

<div id="unique">Unique box</div>
  

🧩 Inline, Internal, and External CSS

✨ Inline CSS

Define styles directly in an element’s style attribute.

<p style="color: red;">This text is red.</p>
  

✨ Internal CSS

Use the <style> tag in the <head> section of your HTML document.

<head>
  <style>
    body {
      font-family: Arial, sans-serif;
    }
  </style>
</head>
  

✨ External CSS

Link an external CSS file using the <link> tag.

<head>
  <link rel="stylesheet" href="styles.css">
</head>
  

πŸ”‘ Best Practice: Use external CSS for better organization and reusability.


πŸŒ€ Vibe Coding Session + AI Partner

"Let AI help you find your visual style as you explore your first styling rules."

πŸ› οΈ AI Tools + Prompts

Tool Use Case Sample Prompts
πŸ’¬ ChatGPT Syntax help, example code - "Give me a basic CSS stylesheet for a dark theme."
- "Explain the difference between class and ID selectors."
πŸ€– Claude Explain selector logic, optimize code - "Clean up and organize this CSS code."
- "Explain how specificity works in CSS selectors."
🌈 Gemini Creative layout ideas - "Suggest a minimal layout for a personal landing page."
- "How to make a sticky header using CSS?"
⚑ GitHub Copilot Suggests complete style blocks Try typing body { or .container { and Copilot will fill values.
πŸ“ Notion AI Writing style guides and naming conventions "Write a color and font style guide for my project."
🎨 Figma AI Design β†’ Code handoff previews "Design a two-column layout and convert it to CSS."

βœ… Challenge

Goal: Create an HTML + CSS page using internal or external stylesheets.

πŸ”— Tip: Click Share to copy a direct link to this section.

🎯 CSS Styling Tutorial β€” Foundations & Basic Properties

πŸŽ“ Objectives

By the end of this tutorial, you will:

πŸ“š Content Overview

1. CSS Basics: Selectors, Properties, and Values (1 Hour)

CSS (Cascading Style Sheets) controls how HTML elements appear on a webpage.

✨ Structure of a CSS Rule

selector {
    property: value;
}

🎯 Example:

h1 {
    color: blue;
    text-align: center;
}

✨ Common Selectors

Element Selector: Targets all instances of an element.

p { font-size: 16px; }

Class Selector: Targets elements with a specific class.

.highlight { background-color: yellow; }

HTML Example:

<p class="highlight">This is highlighted!</p>

ID Selector: Targets a specific element by ID.

#unique { border: 1px solid black; }
<div id="unique">Unique box</div>

✨ Inline, Internal, and External CSS

Inline CSS: Styles written directly in an element.

<p style="color:red;">This text is red.</p>

Internal CSS: Styles inside the <style> tag in the head.

<head>
  <style>
    body { font-family: Arial, sans-serif; }
  </style>
</head>

External CSS: Linked stylesheet for larger projects.

<head>
  <link rel="stylesheet" href="styles.css">
</head>

πŸ”‘ Best Practice: Use external CSS for clean and reusable styles.


🎨 Basic Styling Properties

✨ Colors

h1 {
  color: #3498db;
  background-color: #f1c40f;
}

✨ Font Styles

p {
  font-family: 'Arial', sans-serif;
  font-size: 18px;
  font-weight: bold;
}

✨ Text Alignment

h2 { text-align: center; }

✨ Spacing with Padding and Margin

div {
  padding: 20px;
  margin: 15px;
}

✨ Example of Styling a Button

button {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

πŸŒ€ Vibe Coding Session + AI Remix

"Add rhythm to your code with colors, spacing, and some AI spark."

πŸ› οΈ AI Tools + Prompts

ToolUse CaseSample Prompts
ChatGPTSyntax help & style generation"Style a card with a shadow."
ClaudeRefactor styles"Explain responsive padding."
GeminiModern CSS advice"Flexible layouts with CSS."
CopilotPredict class stylingType .card { and continue.
Figma AIDesign β†’ Code previews"Design a two-column layout with CSS."

βœ… Challenge

πŸ”— Tip: Click Share to copy a direct link to this section.

🎨 Try It Yourself - CSS Basics

Edit the CSS code below and click Run to see the result live!

πŸ“¦ Try It Yourself - CSS Box Model

Introduction to the Box Model: The CSS Box Model describes how every element is structured on a page:

✨ Visual Example:

πŸŒ€ AI-Powered Vibe Coding: Box Mode Activated
"Let’s break the box and rebuild itβ€”with AI as your layout lens."

βœ… Challenge: Build a layout with clear margins, paddings, and borders. Use box-sizing intentionally and test layouts in dev tools.